# -*- coding: utf-8 -*-

from django import template
from django.conf import settings
from django.shortcuts import render_to_response
from django.template import Context
from django.template import Library
from django.template import Node
from widgets.forms import *
from widgets.forms import NoteForm
from widgets.models import Note
register = Library()

class WidgetNotesNode(Node):

    def __init__(self):
        pass
        
    def render(self, context):
        list = Note.objects.all()
        form = NotatkaForm()
        title = 'Notatki'
#            jsfld = settings.MEDIA_URL + 'js/'
#        if(not context.needed_js):
#            context.needed_js = ()
#        context.needed_js.append(jsfld + 'jquery.editinplace.packed.js')

        t = template.loader.get_template('widgets/notatki.html')

        return t.render(Context({'list': list, 'form':form, 'title':title, 'MEDIA_URL':context['MEDIA_URL'], }, autoescape=context.autoescape))
#        return render_to_response('widgets/notatki.html', {'list': list, 'form':form}, None)


@register.tag
def widget_notes(parser, token):
    return WidgetNotesNode()
